﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserGrant.aspx.cs" Inherits="RGPWEB.admin.Modubles.UserGrant" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>用户授权</title>
    <link href="../../inc/Style/index.css" rel="stylesheet" type="text/css" />
    <link href="../../inc/Style/childindex.css" rel="stylesheet" type="text/css" />
    <link href="../../inc/Style/GridView.css" rel="stylesheet" type="text/css" />

    <script language="javascript" type="text/jscript">
        function $id(s) {
            return document.getElementById(s);
        }

        function copyToList(from, to) //from表示:包含可選擇專案的select物件名字 to表示:列出可選擇專案的select物件名字 //你可以根據你的具體情況修改
        {
            fromList = eval('document.forms[0].' + from);
            toList = eval('document.forms[0].' + to);
            if (toList.options.length > 0 && toList.options[0].value == 'temp') {
                toList.options.length = 0;
            }
            var sel = false;
            for (i = 0; i < fromList.options.length; i++) {
                var current = fromList.options[i];
                if (current.selected) {
                    sel = true;
                    if (current.value == 'temp') {
                        alert('不能选择这个角色!');
                        return;
                    }
                    txt = current.text;
                    val = current.value;
                    toList.options[toList.length] = new Option(txt, val);
                    fromList.options[i] = null;
                    i--;
                }
            }
            if (!sel) alert('未选择任何角色!');
        }

        function allSelect() //這是當使用者按下提交按鈕時，對列出選擇的select物件執行全選工作，讓遞交至的幕後程式能取得相關資料
        {
            List = document.forms[0].RoleList;
            if (List.length && List.options[0].value == 'temp') return;
            for (i = 0; i < List.length; i++) {
                List.options[i].selected = true;
            }
        }

        function getdata() {
            var List = document.forms[0].RoleList;
            var roles = $id("TRoleList");
            roles.value = "";
            var s = "";
            if (List.length != 0) {
                for (i = 0; i < List.length; i++) {
                    s += List.options[i].value + ",";
                }
            }

            roles.value = s;
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:Panel ID="TitlePanel" runat="server" CssClass="titlePadding">
        给<asp:Label ID="UNAME" runat="server" ForeColor="Red"></asp:Label>授权<asp:Label ID="UID"
            runat="server" Text="" Style="display: none;"></asp:Label>，<asp:Label ID="Label2"
                runat="server" Text="允许和禁止都被选中或为空将删除该权限" ForeColor="#FF6600"></asp:Label>
        <asp:Label ID="TID" runat="server" Text="" Style="display: none;"></asp:Label>
    </asp:Panel>
    <asp:Panel ID="ChildPanel" runat="server">
        <div class="rowdiv" style="margin-left: 3px;">
            请选择授权类型：</div>
        <div class="rowdiv">
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                <asp:ListItem Selected="True" Value="0">模块授权</asp:ListItem>
                <asp:ListItem Value="1">用户角色</asp:ListItem>
            </asp:DropDownList>
        </div>
    </asp:Panel>
    <div id="strinfo" runat="server" class="mbox pbox" visible="false">
    </div>
    <div class="gv">
        <asp:Panel ID="ModelPanel" runat="server">
            <div style="float: left;">
                <asp:GridView ID="ModuleTypeView" Width="100px" runat="server" DataKeyNames="ModuleTypeID"
                    AllowSorting="True" OnRowCommand="ModuleType_RowCommand" AutoGenerateColumns="False"
                    ShowHeader="False" GridLines="None">
                    <Columns>
                        <asp:BoundField DataField="ModuleTypeID" HeaderText="编号" Visible="false">
                            <ItemStyle HorizontalAlign="Center" Wrap="false" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderText="名称">
                            <ItemTemplate>
                                <asp:LinkButton ID="lbtn_name" CommandArgument='<%# Eval("ModuleTypeID")%>' CommandName="EditView"
                                    runat="server" Text='<%# Eval("ModuleTypeName") %>' ToolTip='<%# Eval("ModuleTypeDescription") %>'></asp:LinkButton>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Left" Width="100px" Height="24px" />
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
            </div>
            <div style="float: left; margin-left: 10px;">
                <asp:GridView ID="ModuleView" Width="100px" runat="server" DataKeyNames="ModuleID"
                    CssClass="Grid" AllowSorting="True" AutoGenerateColumns="False" OnRowDataBound="ModuleView_RowDataBound"
                    OnSelectedIndexChanging="ModuleView_SelectedIndexChanging">
                    <FooterStyle CssClass="GridFooter" />
                    <RowStyle CssClass="Row" />
                    <Columns>
                        <asp:TemplateField HeaderText="模块名称">
                            <ItemTemplate>
                                <asp:Label ID="lab_ID" runat="server" Text='<%# Eval("ModuleID")%>' Style="display: none"></asp:Label>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("ModuleName") %>'></asp:Label>
                                <asp:Label ID="lab_Verify" runat="server" Text="" Style="display: none"></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Wrap="False" />
                            <ItemStyle HorizontalAlign="Left" Wrap="False" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="权限列表">
                            <ItemTemplate>
                                <table border="0" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td style="white-space: nowrap;">
                                            <div align="center" style="color: #339900;">
                                                允许</div>
                                        </td>
                                        <td style="white-space: nowrap;">
                                            <asp:CheckBoxList ID="AuthorityList_Grant" runat="server" RepeatDirection="Horizontal"
                                                RepeatLayout="Flow">
                                            </asp:CheckBoxList>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="white-space: nowrap;">
                                            <div align="center" style="color: #FF0000;">
                                                禁止</div>
                                        </td>
                                        <td style="white-space: nowrap;">
                                            <asp:CheckBoxList ID="AuthorityList_Deny" runat="server" RepeatDirection="Horizontal"
                                                RepeatLayout="Flow">
                                            </asp:CheckBoxList>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                            <HeaderStyle Wrap="False" />
                            <ItemStyle Wrap="False" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText=" 更新 ">
                            <ItemTemplate>
                                <asp:LinkButton ID="btn_update" runat="server" CommandArgument='<%# Eval("ModuleID")%>'
                                    CausesValidation="False" CommandName="Select" Text="更新"></asp:LinkButton>
                            </ItemTemplate>
                            <HeaderStyle Wrap="False" />
                            <ItemStyle Wrap="False" />
                        </asp:TemplateField>
                    </Columns>
                    <HeaderStyle CssClass="HeadingCell" />
                    <AlternatingRowStyle BorderStyle="None" CssClass="AlternatingRow" />
                </asp:GridView>
                <div style="height: 24px; line-height: 24px; margin-top: 5px;">
                    <asp:Button ID="btn_AllSave" runat="server" Visible="false" CssClass="smallbtn" Text="保存全部"
                        OnClick="btn_AllSave_Click" />
                </div>
            </div>
        </asp:Panel>
        <asp:Panel ID="RolePanel" runat="server">
            <table width="500" border="0" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
                <tr>
                    <td width="200" height="30" bgcolor="#CCCCCC">
                        <div align="center">
                            用户角色</div>
                    </td>
                    <td width="100" bgcolor="#CCCCCC">
                        <div align="center" style="color: #FFFFFF;">
                        </div>
                    </td>
                    <td width="200" bgcolor="#CCCCCC">
                        <div align="center">
                            系统角色列表</div>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#FFFFFF">
                        <div align="center" style="margin: 10px;">
                            <asp:ListBox ID="RoleList" runat="server" Style="width: 160px;" SelectionMode="Multiple"
                                Height="205px"></asp:ListBox>
                            <asp:TextBox ID="OldRoleList" runat="server" Style="display: none;"></asp:TextBox>
                            <asp:TextBox ID="TRoleList" runat="server" Style="display: none;"></asp:TextBox>
                        </div>
                    </td>
                    <td bgcolor="#FFFFFF">
                        <div align="center">
                            <input id="btn_plus" type="button" value="   <<   " onclick="javascript:copyToList('FromRoleList','RoleList')" /><br />
                            <br />
                            <input id="btn_subtract" type="button" value="   >>   " onclick="javascript:copyToList('RoleList','FromRoleList')" /><br />
                            <br />
                            <asp:Button ID="btn_saverole" runat="server" Text=" 保 存 " OnClick="btn_saverole_Click" /><br />
                            <br />
                            按下CTRL鍵<br />
                            可以多選
                        </div>
                    </td>
                    <td bgcolor="#FFFFFF">
                        <div align="center" style="margin: 10px;">
                            <asp:ListBox ID="FromRoleList" runat="server" Style="width: 160px;" SelectionMode="Multiple"
                                Height="205px"></asp:ListBox>
                        </div>
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </div>
    </form>
</body>
</html>
